﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SN.UserControl
{
    public partial class frmSetSize : Form
    {
        public int rows;
        public int cols;

        public frmSetSize()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            
            if (string.IsNullOrWhiteSpace(textBox1.Text.Trim()))
            {
                MessageBox.Show("行数不能为空!");
                return;
            }
            //
            if (string.IsNullOrWhiteSpace(textBox2.Text.Trim()))
            {
                MessageBox.Show("列数不能为空!");
                return;
            }

            rows = Convert.ToInt16(textBox1.Text.Trim());
            cols = Convert.ToInt16(textBox2.Text.Trim());

            if (rows > 255)
            {
                MessageBox.Show("列数不能大于255!");
                return;
            }
            if (cols > 65535)
            {
                MessageBox.Show("行数不能大于65535!");
                return;
            }
            DialogResult = DialogResult.OK;
            Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void frmSetSize_Load(object sender, EventArgs e)
        {
            textBox1.Text = rows.ToString();
            textBox2.Text = cols.ToString();
        }
    }
}
